﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Rappelz.GameServer
{
    public class TimeSyncer
    {
        public TimeSyncer(int L, int DC, int MAX)
        {
            m_L = L;
            m_DC = DC;
            m_MAX = MAX;
        }

//        Function       :   public void TimeSyncer(const class TimeSyncer &)
        
        public void onEcho(uint t)
        {
            if (m_vT.Count == m_MAX)
            {
//                 m_vT.
//                 std::_Vector_const_iterator<StateDamage_std::allocator<StateDamage>>::_Vector_const_iterator<StateDamage_std::allocator<StateDamage>>(
//                     &thisa,
//                     *(v2 + 1),
//                     v2);
//                 v3 = std::_Vector_const_iterator<PartyManager::PartyInfo___std::allocator<PartyManager::PartyInfo__>>::operator_(&thisa);
//                 LODWORD(v3->end.x) = T;
            }
            else
            {
                m_vT.Add(t);
            }

        }
        
        public uint GetInterval()
        {
            uint tc = 0;
            int CDC = 0;
            uint size = (uint)m_vT.Count;

            foreach (uint i in m_vT)
            {
                if (i < m_L || CDC >= m_DC)
                {
                    ++size;
                    tc += i;
                }
                CDC++;
            }
            return tc / size >> 1;
        }
        
        public uint GetTestCount()
        {
            return 0;
        }

        public int m_L;
        public int m_DC;
        public int m_MAX;
        public List<uint> m_vT = new List<uint>();
    }
}
